package com.wc.AlgoOJ_homework.AlgoOJ_BL2.H_子串简写;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/4/1 19:27
 * @description http://43.138.190.70:8888/p/1127?tid=6602a6e518e03a818a4bf047
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 500010;
    static char[] s;
    static int[] c1Idx = new int[N];
    static int[] c2Idx = new int[N];
    static int k;
    static char c1, c2;

    public static void main(String[] args) {
        k = sc.nextInt();
        s = (" " + sc.next()).toCharArray();
        c1 = sc.next().charAt(0);
        c2 = sc.next().charAt(0);
        int n = s.length - 1;
        for (int i = 1; i <= n; i++) {
            if (s[i] == c1) {
                c1Idx[++c1Idx[0]] = i;
            }
            if (s[i] == c2) {
                c2Idx[++c2Idx[0]] = i;
            }
        }
        long res = 0;
        for (int i = 1; i <= c1Idx[0]; i++) {
            if (c2Idx[c2Idx[0]] - c1Idx[i] + 1 < k) {
                break;
            } else {
                int l = 1, r = c2Idx[0];
                while (l < r) {
                    int mid = l + r >> 1;
                    if (c2Idx[mid] - c1Idx[i] + 1 >= k) r = mid;
                    else l = mid + 1;
                }
                res += (c2Idx[0] - l + 1);
            }
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}